import Vue from 'vue'
import Vuex from 'vuex'
import { EXAMPLE, TABS } from './mutation-types.js'

Vue.use(Vuex)

export const store = new Vuex.Store({
	state: {
		notification: new Vue(),
		questionId: '',
		articleId: ''
	},
	mutations: {
		questionID(state, id) {
			state.questionId = id
		},
		articleID(state, id) {
			state.articleId = id
		}
	},
	actions: {},
	getters: {}
})

store.registerModule('menu', {
	state: {
		menuList: [
			{
				id: '0',
				name: '用户管理',
				icon: 'ios-chatboxes',
				children: [
					{
						id: '0-1',
						name: '角色列表',
						icon: 'ios-people',
						path: '/roles'
					},
					{
						id: '0-2',
						name: '权限列表',
						icon: 'md-send',
						path: '/rights'
					}
				]
			},
			{
				id: '1',
				name: '题库管理',
				icon: 'ios-paper',
				children: [
					{
						id: '1-1',
						name: '基础题库',
						icon: 'md-school',
						path: '/questions'
					},
					{
						id: '1-2',
						name: '试题录入',
						icon: 'md-paper',
						path: '/questions/add'
					}
				]
			},
			{
				id: '2',
				name: '学科管理',
				icon: 'md-mail',
				children: [
					{
						id: '2-1',
						name: '学科列表',
						icon: 'ios-list-box',
						path: '/subject'
					},
					{
						id: '2-2',
						name: '学科标签',
						icon: 'ios-pricetags',
						path: '/tags'
					}
				]
			},
			{
				id: '3',
				name: '面试技巧',
				icon: 'md-star',
				children: [
					{
						id: '3-1',
						name: '文章列表',
						icon: 'md-print',
						path: '/articles'
					},
					{
						id: '3-2',
						name: '新增技巧',
						icon: 'ios-planet',
						path: '/articles/add'
					}
				]
			}
		],
		tabs: [
			{
				label: '主页',
				closable: false,
				path: '/index',
				icon: 'ios-leaf'
			}
		]
	},
	mutations: {
		[TABS](state, tabs) {
			state.tabs = tabs
		}
	}
})

store.registerModule('config', {
	state: {
		pageSizeArr: [10, 15, 20],
		defaultPageSize: 10
	}
})
